// fileName      :  router.go
// createdAt     :  2021-09-27
// description   :

package router

import (
	"github.com/gin-gonic/gin"
	"log"
	"zl-gin/controllers/v1"
	"zl-gin/middlewares"
)

func InitRouter() *gin.Engine {
	log.Println("init router...")

	e := gin.New()
	e.Use(middlewares.Tracer)
	//e.Use(middlewares.GinLogger, gin.Recovery())
	e.Use(gin.Recovery())

	groupV1 := e.Group("v1/")
	{
		groupV1.GET("/test", v1.MyTest)

		groupV1.GET("user/auth", v1.UserLogin)
		groupV1.POST("user/register", v1.UserRegister)

		//需要验证
		groupV1.Use(middlewares.Auth)
		groupV1.POST("user", v1.Userinfo)
	}

	return e
}
